package org.yaac.server.egql;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import org.yaac.server.egql.evaluator.Evaluator;

/**
 * @author Max Zhu (thebbsky@gmail.com)
 *
 */
public class SelectClause implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 
	 */
	private List<Evaluator> items;

	/**
	 * @param items
	 */
	public SelectClause() {
		this.items = new LinkedList<Evaluator>();
	}

	/**
	 * @param e
	 */
	public SelectClause add(Evaluator e) {
		this.items.add(e);
		return this;
	}
	
	/**
	 * @return
	 */
	public List<Evaluator> getItems() {
		return items;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((items == null) ? 0 : items.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SelectClause other = (SelectClause) obj;
		if (items == null) {
			if (other.items != null)
				return false;
		} else if (!items.equals(other.items))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return "SelectClause [items=" + items + "]";
	}
}
